package net.mcg_server.jbi.gui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.mcg_server.jbi.Program;
import net.mcg_server.jbi.gui.menu.MenuBar;

public class ManageGames {

	// -------------
	// VARIABLES
	// -------------
	private JFrame frame;
	private JPanel panel;
	private boolean SHOULD_FILL = true;
	private Program program;

	public ManageGames(Program program) {
		initialize();
		frame.setVisible(true);
		this.program = program;
	}

	private void initialize() {
		// create the frame
		frame = new JFrame("Manage Games");
		frame.setBounds(250, 200, 400, 300);
		frame.toFront();
		frame.setResizable(false);

		// create the panel
		panel = new JPanel(new GridBagLayout());

		// define layout constraints
		GridBagConstraints c = new GridBagConstraints();
		if (SHOULD_FILL) {
			c.fill = GridBagConstraints.HORIZONTAL;
		}

		// add panel to frame
		frame.add(panel);

		// add page description
		JLabel description = new JLabel();
		description.setText("This is the Manage Page description");
		c.gridx = GridBagConstraints.NORTH;
		c.gridy = 0;
		panel.add(description, c);

		// ------------
		// LISTENERS
		// ------------

		// close AccountManageWindow
		frame.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if (true) {
					MenuBar.menuOpened = false;
					program.getMainFrame().requestFocus();
					frame.dispose();
				}
			}
		});

		frame.addWindowFocusListener(new WindowAdapter() {
			@Override
			public void windowLostFocus(WindowEvent e) {
				frame.requestFocus();
			}
		});
	}

}
